'use strict';
import React, { Component } from 'react';
import {
    AppRegistry,
    StyleSheet,
    PixelRatio,
    Text,
    View,
	Image,
	TouchableWithoutFeedback,
	Platform
} from 'react-native';
//公共组件
import css from './common_css'
import dp from './pxToDp'
class BackAndTitle extends Component{
    constructor(props) {
      	super(props);
      	this.state = {

      	};
    }
	//返回上一页
	back(){
		const {navigator}=this.props.navigator
		if(navigator){
			navigator.pop()
		}
	}
    render(){
		var iosdiv=null;
		if (Platform.OS === 'ios') {
			iosdiv=(
				<View style={{height:dp(20)}}></View>
			)
		}
		return(
			<View style={[s.body]}>
				{iosdiv}
				<View style={[s.height54,s.header,s.flexRow]}>
					<View style={[s.width54,s.height54,s.center]}>
						<TouchableWithoutFeedback
							onPress={this.back.bind(this)}
							>
							<Image
		                        source={require('../image/back.png')}
								style={[s.width20,s.height20]}
								resizeMode="contain"
							></Image>
						</TouchableWithoutFeedback>
					</View>
					<View style={[s.flex1,s.height54,s.center]}>
						<Text style={[s.tc,s.fontBold,s.font18,s.fontColor]}>{this.props.title}</Text>
					</View>
					<View style={[s.width54,s.height54,s.center]}>
					</View>
				</View>
			</View>
		)
    }
}

const s = StyleSheet.create(Object.assign(css,{
	body:{
		borderBottomWidth:dp(1),
		borderColor:'#ddd'
	},
	fontColor:{
		color:'#000'
	}
}));

module.exports=BackAndTitle;
